package main

import (
	"fmt"
	"sync"
)

type DB struct {
	Database string
}

var db *DB
var once sync.Once

func GetDB() *DB {
	once.Do(func() {
		db = &DB{
			Database: "fengfeng",
		}
	})
	return db
}

func main() {
	d := GetDB()
	fmt.Printf("%p, %v\n", d, d.Database)
	d = GetDB()
	fmt.Printf("%p, %v\n", d, d.Database)
}
